﻿/*----------------------------------------------------------------------------------------------------------------
  ----------------------------------------------------------------------------------------------------------------
  -- https://github.com/danielpalme/MVCBlog/blob/master/Setup/DB-Schema.sqlce
  ----------------------------------------------------------------------------------------------------------------
  ---------------------------------------------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------------------------------------------
  ----------------------------------------------------------------------------------------------------------------
  -- CONVERT UNIQUEIDENTIFIER TO VARCHAR --
  ----------------------------------------------------------------------------------------------------------------
  ---------------------------------------------------------------------------------------------------------------*/

/*
DECLARE @uuid VARCHAR(50)
SET @uuid = 'a89b1acd95016ae6b9c8aabb07da2010'
SELECT  CAST(
        SUBSTRING(@uuid, 1, 8) + '-' + SUBSTRING(@uuid, 9, 4) + '-' + SUBSTRING(@uuid, 13, 4) + '-' +
        SUBSTRING(@uuid, 17, 4) + '-' + SUBSTRING(@uuid, 21, 12)
        AS UNIQUEIDENTIFIER)
*/

/*---------------------------------------------------------------------------------------------------------------
  ---------------------------------------------------------------------------------------------------------------

  -- CONVERT UNIQUEIDENTIFIER TO VARCHAR --
  ---------------------------------------------------------------------------------------------------------------
  ---------------------------------------------------------------------------------------------------------------*/

  -- DECLARE @UniqueIdentifier VARCHAR(50)
  -- CONVERT(nvarchar(10),@UniqueIdentifier)

  ----------------------------------------------------------------------------------------------------------------
  ---------------------------------------------------------------------------------------------------------------*/

/*
declare @sql nvarchar(4000)
set @sql = 'select
				t.[PortalID],
				t.[City],
				t.[Name],
				t.[Code],
				ts.*
			 from [Hockey_Team_Statistics] ts inner join [Hockey_Teams] t on (t.[TeamID] = ts.[TeamID])
			 where ' + 
			 ' ts.[SeasonYear] = ' + CONVERT(nvarchar(10),@SeasonYear) + ' and ' + 
			 ' ts.[LeagueMode] = ' + CONVERT(nvarchar(1),@LeagueMode) + ' and ' + 
			 ' t.[PortalID] = ' + @PortalID + 
			 ' order by ' + @SortExpression + ''
exec sp_executesql @sql
*/

/*----------------------------------------------------------------------------------------------------------------
  ----------------------------------------------------------------------------------------------------------------

  -- VIEW SECURITY --

  ----------------------------------------------------------------------------------------------------------------
  ---------------------------------------------------------------------------------------------------------------*/

--select dbo.ufnGetName(UR.UserId) AS [UserName]
--, R.RoleName
--, O.Name AS [OrgName]
--from UsersInRoles UR
--join Organizations O on UR.OrgId = O.Id
--join Roles R on R.RoleId = UR.RoleId


--select dbo.ufnGetName(UR.UserId) AS [UserName]
--, R.RoleName
--, O.Name AS [OrgName]
--from UsersInRoles UR
--join Companies C on UR.OrgId = C.Id
--join Roles R on R.RoleId = UR.RoleId